home *** CD-ROM | disk | FTP | other *** search
- static char rcsid[]=
- "$Header: /usr/people/millard/DBglxwidget/RCS/GlxDraw.c,v 1.2 1994/01/01 22:31:41 millard Exp millard $";
- /*
- * These files are for informational purposes and can demonstrate how
- * to write your own mixed-mode GL-based widgets. However SGI does not
- * guarantee that this source code absolutely matches the GLxDraw
- * widget that is shipped as part of the system.
- *
- * New Version by Chris Carlson and Ed Millard
- * supports switching between single and double buffering
- */
-
- /***********************************************************
- Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
- and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
-
- All Rights Reserved
-
- Permission to use, copy, modify, and distribute this software and its
- documentation for any purpose and without fee is hereby granted,
- provided that the above copyright notice appear in all copies and that
- both that copyright notice and this permission notice appear in
- supporting documentation, and that the names of Digital or MIT not be
- used in advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
- ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
- DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
- ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
- ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- SOFTWARE.
-
- ******************************************************************/
-
-
- /*------------------------------------------------------------------------
- * III N N CCC L U U DDDD EEEEE SSS
- * I NN N C C L U U D D E S S
- * I NN N C L U U D D E S
- * I N N N C L U U D D EEE SSS
- * I N NN C L U U D D E S
- * I N NN C C L U U D D E S S
- * III N N CCC LLLLL UUU DDDD EEEEE SSS
- *------------------------------------------------------------------------*/
-
- #ifdef DEBUG
- #include <stdio.h>
- #endif
-
- #include <X11/IntrinsicP.h>
- #include <X11/StringDefs.h>
-
- #include <X11/Xatom.h>
- #include <X11/Xutil.h>
- #ifdef USE_GL
- #include <gl/get.h>
- #else
- #endif /* USE_GL */
-
- #ifdef __GLX_MOTIF
- #include <Xm/XmP.h>
-
- #ifdef SVR4
- #include <Xm/PrimitiveP.h>
- #endif
-
- #include "GlxMDrawP.h"
-
- #else /* not __GLX_MOTIF */
-
- #include "GlxDrawP.h"
-
- #endif /* __GLX_MOTIF */
-
- /*------------------------------------------------------------------------
- * DDDD EEEEE FFFFF III N N EEEEE SSS
- * D D E F I NN N E S S
- * D D E F I NN N E S
- * D D EEE FFF I N N N EEE SSS
- * D D E F I N NN E S
- * D D E F I N NN E S S
- * DDDD EEEEE F III N N EEEEE SSS
- *------------------------------------------------------------------------*/
-
- #ifdef __GLX_MOTIF
- /* The MOTIF version differs only in the inclusion of the primitive
- * widget class and in a vew variable and type name differences.
- * Rather than put ifdefs all over the place, we just use a few defines
- * to make it use motif types and names
- */
- #define GlxDrawWidget GlxMDrawWidget
- #define GlxDrawClassRec GlxMDrawClassRec
- #define glxDrawClassRec glxMDrawClassRec
- #define glxDrawWidgetClass glxMDrawWidgetClass
- #define GlxDrawRec GlxMDrawRec
- #endif /* __GLX_MOTIF */
-
- #define MAX_CONFIG 128
-
- /*----
- * Explanation of DEBUG definitions:
- * bitmap enables
- * ------ -------
- * defnd Calls XSynchronize before doing 'Initialize'.
- * 0x0002 Print colormap info
- * 0x0004 Print window IDs
- * 0x0008 Print visual info
- * 0xFFFE Will print info useful to all of the above
- *----*/
-
- /*------------------------------------------------------------------------
- * M M AAA CCC RRRR OOO SSS
- * MM MM A A C C R R O O S S
- * MM MM A A C R R O O S
- * M M M AAAAA C RRRR O O SSS
- * M M A A C R R O O S
- * M M A A C C R R O O S S
- * M M A A CCC R R OOO SSS
- *------------------------------------------------------------------------*/
-
- #define offset(field) XtOffset(GlxDrawWidget, glxDraw.field)
-
- /*------------------------------------------------------------------------
- * L OOO CCC AAA L SSS
- * L O O C C A A L S S
- * L O O C A A L S
- * L O O C AAAAA L SSS
- * L O O C A A L S
- * L O O C C A A L S S
- * LLLLL OOO CCC A A LLLLL SSS
- *------------------------------------------------------------------------*/
-
- static char defaultTranslations[] =
- "<KeyDown>: glxInput() \n\
- <KeyUp>: glxInput() \n\
- <BtnDown>: glxInput() \n\
- <BtnUp>: glxInput() \n\
- <BtnMotion>: glxInput() ";
-
- static void glxInput();
- static void auxwindow_destroyed();
-
- #ifdef USE_GL
- static GLXconfig default_config[] = {{0,0,0}};
- #else
- static int default_config[] = {
- GLX_RGBA,
- GLX_RED_SIZE,3,
- GLX_BLUE_SIZE,3,
- GLX_GREEN_SIZE,3,
- GLX_DEPTH_SIZE,12,
- GLX_DOUBLEBUFFER,
- None,
- };
- #endif /* USE_GL */
-
- static XtActionsRec actions[] = {
- { "glxInput", glxInput }, /* key or mouse input */
- };
-
- static XtResource resources[] = {
- #ifdef USE_GL
- {GlxNglxConfig, GlxCGlxConfig, GlxRGlxConfig, sizeof(GLXconfig *),
- offset(config),
- XtRImmediate, (caddr_t) default_config},
- #else
- {GlxNglxConfig, GlxCGlxConfig, GlxRGlxConfig, sizeof(int *),
- offset(config),
- XtRImmediate, (caddr_t) default_config},
-
- {GlxNglxContext, GlxCGlxContext, GlxRGlxContext, sizeof (GLXContext *),
- offset(context),
- XtRImmediate, (caddr_t) 0},
- #endif /* USE_GL */
-
- {GlxNginitCallback, GlxCCallback, XtRCallback, sizeof (XtCallbackList),
- offset(ginit_callback), XtRImmediate, (caddr_t) NULL},
-
- {GlxNinputCallback, GlxCCallback, XtRCallback, sizeof (XtCallbackList),
- offset(input_callback), XtRImmediate, (caddr_t) NULL},
-
- {GlxNresizeCallback, GlxCCallback, XtRCallback, sizeof (XtCallbackList),
- offset(resize_callback), XtRImmediate, (caddr_t) NULL},
-
- {GlxNexposeCallback, GlxCCallback, XtRCallback, sizeof (XtCallbackList),
- offset(expose_callback), XtRImmediate, (caddr_t) NULL},
-
- {GlxNvisualInfo, GlxCVisualInfo, GlxRVisualInfo, sizeof (XVisualInfo *),
- offset(visualInfo), XtRImmediate, (caddr_t) NULL},
-
- {GlxNoverrideColormap, GlxCOverrideColormap, XtRBoolean, sizeof (Boolean),
- offset(override_colormap), XtRImmediate, (caddr_t) TRUE},
-
- {GlxNuseOverlay, GlxCUseOverlay, XtRBoolean, sizeof (Boolean),
- offset(overlay_info.exists), XtRImmediate, (caddr_t) FALSE},
-
- {GlxNoverlayWindow, GlxCWindow, XtRWindow, sizeof (Window),
- offset(overlay_info.window), XtRImmediate, (caddr_t) 0},
-
- {GlxNoverlayColormap, GlxCColormap, XtRColormap, sizeof (Colormap),
- offset(overlay_info.colormap), XtRImmediate, (caddr_t) 0},
-
- {GlxNoverlayDepth, GlxCDepth, XtRInt, sizeof (int),
- offset(overlay_info.depth), XtRImmediate, (caddr_t) 0},
-
- {GlxNoverlayVisual, GlxCVisualInfo, GlxRVisualInfo, sizeof (XVisualInfo *),
- offset(overlay_info.visualInfo), XtRImmediate, (caddr_t) 0},
- #ifndef USE_GL
- {GlxNoverlayGlxConfig, GlxCGlxConfig, GlxRGlxConfig, sizeof(int *),
- offset(overlay_info.config),
- XtRImmediate, (caddr_t) 0},
-
- {GlxNoverlayGlxContext, GlxCGlxContext, GlxRGlxContext, sizeof (GLXContext *),
- offset(overlay_info.context), XtRImmediate, (caddr_t) 0},
- #endif
-
- {GlxNoverlayExposeCallback, GlxCCallback, XtRCallback,
- sizeof (XtCallbackList),
- offset(overlay_info.expose_callback), XtRImmediate, (caddr_t) NULL},
-
- {GlxNuseUnderlay, GlxCUseUnderlay, XtRBoolean, sizeof (Boolean),
- offset(underlay_info.exists), XtRImmediate, (caddr_t) FALSE},
-
- {GlxNunderlayWindow, GlxCWindow, XtRWindow, sizeof (Window),
- offset(underlay_info.window), XtRImmediate, (caddr_t) 0},
-
- {GlxNunderlayColormap, GlxCColormap, XtRColormap, sizeof (Colormap),
- offset(underlay_info.colormap), XtRImmediate, (caddr_t) 0},
-
- {GlxNunderlayDepth, GlxCDepth, XtRInt, sizeof (int),
- offset(underlay_info.depth), XtRImmediate, (caddr_t) 0},
-
- {GlxNunderlayVisual, GlxCVisualInfo, GlxRVisualInfo, sizeof (XVisualInfo *),
- offset(underlay_info.visualInfo), XtRImmediate, (caddr_t) 0},
-
- {GlxNunderlayExposeCallback, GlxCCallback, XtRCallback,
- sizeof (XtCallbackList),
- offset(underlay_info.expose_callback), XtRImmediate, (caddr_t) NULL},
-
- {GlxNusePopup, GlxCUsePopup, XtRBoolean, sizeof (Boolean),
- offset(popup_info.exists), XtRImmediate, (caddr_t) FALSE},
-
- {GlxNpopupWindow, GlxCWindow, XtRWindow, sizeof (Window),
- offset(popup_info.window), XtRImmediate, (caddr_t) 0},
-
- {GlxNpopupColormap, GlxCColormap, XtRColormap, sizeof (Colormap),
- offset(popup_info.colormap), XtRImmediate, (caddr_t) 0},
-
- {GlxNpopupDepth, GlxCDepth, XtRInt, sizeof (int),
- offset(popup_info.depth), XtRImmediate, (caddr_t) 0},
-
- {GlxNpopupVisual, GlxCVisualInfo, GlxRVisualInfo, sizeof (XVisualInfo *),
- offset(popup_info.visualInfo), XtRImmediate, (caddr_t) 0},
-
- {GlxNpopupExposeCallback, GlxCCallback, XtRCallback, sizeof (XtCallbackList),
- offset(popup_info.expose_callback), XtRImmediate, (caddr_t) NULL},
-
- {GlxNmainWindow, GlxCWindow, XtRWindow, sizeof (Window),
- offset (mainWindow), XtRImmediate, (caddr_t) 0},
-
- {GlxNprovideSingleBuffer, GlxCProvideSingleBuffer, XtRBoolean,
- sizeof (Boolean),
- offset(provide_Sbuffer), XtRImmediate, (caddr_t) NULL},
-
- {GlxNsingleBuffer, GlxCSingleBuffer, XtRBoolean, sizeof (Boolean),
- offset(single_buffer), XtRImmediate, (caddr_t) NULL},
-
- {GlxNprovideStereoBuffer, GlxCProvideStereoBuffer, XtRBoolean,
- sizeof (Boolean),
- offset(provide_StereoBuffer), XtRImmediate, (caddr_t) NULL},
-
- {GlxNstereoBuffer, GlxCStereoBuffer, XtRBoolean, sizeof (Boolean),
- offset(stereo_buffer), XtRImmediate, (caddr_t) NULL},
-
- {GlxNaltColormap, GlxCColormap, XtRColormap, sizeof (Colormap),
- offset(alt_colormap), XtRImmediate, (caddr_t)0},
-
- #ifdef __GLX_MOTIF
- /* Primitive resources */
- {XmNtraversalOn, XmCTraversalOn, XmRBoolean, sizeof (Boolean),
- XtOffset (GlxDrawWidget, primitive.traversal_on), XmRImmediate,
- (caddr_t) FALSE},
-
- {XmNhighlightOnEnter, XmCHighlightOnEnter, XmRBoolean, sizeof (Boolean),
- XtOffset (GlxDrawWidget, primitive.highlight_on_enter), XmRImmediate,
- (caddr_t) FALSE},
-
- {XmNshadowThickness, XmCShadowThickness, XmRHorizontalDimension,
- sizeof (Dimension),
- XtOffset (GlxDrawWidget, primitive.shadow_thickness), XmRImmediate,
- (caddr_t) 0},
-
- {XmNhighlightThickness, XmCHighlightThickness, XmRHorizontalDimension,
- sizeof (Dimension),
- XtOffset (GlxDrawWidget, primitive.highlight_thickness), XmRImmediate,
- (caddr_t) 0},
- #endif /* __GLX_MOTIF */
-
- #undef offset
- };
-
- static void
- ClassInitialize(),
- Initialize(),
- Realize(),
- CreateWindow(),
- Redraw(),
- Resize(),
- Destroy();
- static Boolean
- SetValues();
-
- /*------------------------------------------------------------------------
- * GGG L OOO BBBB AAA L SSS
- * G G L O O B B A A L S S
- * G L O O B B A A L S
- * G L O O BBBB AAAAA L SSS
- * G GGG L O O B B A A L S
- * G G L O O B B A A L S S
- * GGG LLLLL OOO BBBB A A LLLLL SSS
- *------------------------------------------------------------------------*/
-
- GlxDrawClassRec glxDrawClassRec =
- {
- { /* core fields */
- #ifdef __GLX_MOTIF
- /* superclass */ (WidgetClass) &xmPrimitiveClassRec,
- /* class_name */ "GlxMDraw",
- #else /* not __GLX_MOTIF */
- /* superclass */ (WidgetClass) &widgetClassRec,
- /* class_name */ "GlxDraw",
- #endif /* __GLX_MOTIF */
- /* widget_size */ sizeof(GlxDrawRec),
- /* class_initialize */ ClassInitialize,
- /* class_part_initialize */ NULL,
- /* class_inited */ FALSE,
- /* initialize */ Initialize,
- /* initialize_hook */ NULL,
- /* realize */ Realize,
- /* actions */ actions,
- /* num_actions */ XtNumber(actions),
- /* resources */ resources,
- /* num_resources */ XtNumber(resources),
- /* xrm_class */ NULLQUARK,
- /* compress_motion */ TRUE,
- /* compress_exposure */ TRUE,
- /* compress_enterleave */ TRUE,
- /* visible_interest */ TRUE,
- /* destroy */ Destroy,
- /* resize */ Resize,
- /* expose */ Redraw,
- /* set_values */ SetValues,
- /* set_values_hook */ NULL,
- /* set_values_almost */ XtInheritSetValuesAlmost,
- /* get_values_hook */ NULL,
- /* accept_focus */ NULL,
- /* version */ XtVersion,
- /* callback_private */ NULL,
- /* tm_table */ defaultTranslations,
- /* query_geometry */ XtInheritQueryGeometry,
- /* display_accelerator */ XtInheritDisplayAccelerator,
- /* extension */ NULL
- },
- #ifdef __GLX_MOTIF /* primitive resources */
- {
- /* border_highlight */ XmInheritBorderHighlight,
- /* border_unhighlight */ XmInheritBorderUnhighlight,
- /* translations */ XtInheritTranslations,
- /* arm_and_activate */ NULL,
- /* get_resources */ NULL,
- /* num get_resources */ 0,
- /* extension */ NULL,
- }
- #endif /* __GLX_MOTIF */
- };
- WidgetClass glxDrawWidgetClass = (WidgetClass)&glxDrawClassRec;
-
- /*------------------------------------------------------------------------
- * error
- *------------------------------------------------------------------------*/
-
- static char *gl_errs[] = {
- "No error", "No context", "No display", "No window", "No graphics",
- "Not top", "No visual", "Buffer size too small", "Bad window",
- };
-
- static void error(w,string)
- Widget w;
- char *string;
- {
- char buf[100];
- #ifdef __GLX_MOTIF
- sprintf (buf, "GlxMDraw: %s\n", string);
- #else
- sprintf (buf, "GlxDraw: %s\n", string);
- #endif
- XtAppError(XtWidgetToApplicationContext(w), buf);
- }
-
- /*------------------------------------------------------------------------
- * warning
- *------------------------------------------------------------------------*/
-
- static void warning(w,string)
- Widget w;
- char *string;
- {
- char buf[100];
- #ifdef __GLX_MOTIF
- sprintf (buf, "GlxMDraw: %s\n", string);
- #else
- sprintf (buf, "GlxDraw: %s\n", string);
- #endif
- XtAppWarning(XtWidgetToApplicationContext(w), buf);
- }
-
- /*------------------------------------------------------------------------
- * Documentation
- * I thought it would be appropriate to document some of the more
- * confusing stuff here. It's actually here to help me remember
- * what's going on.
- *
- * ClassInitialize
- * [Called by: X]
- * Called when widgets of this class are to be initialized.
- *
- * Initialize
- * [Called by: X]
- * Called to initialize the widget.
- * 1. Fills in default values for widget structure.
- * 2. Uses the resources to figure out visuals and
- * colormaps to be used.
- * 3. If both single and double buffered windows are
- * to exist, fill in all the same sort of stuff
- * for the second window.
- *
- * SetValuesAux
- * [Called by: SetAux]
- * [Calls: XChangeWindowAttributes]
- * Used to set up common resources for overlay, underlay
- * and popup windows. Calls XChangeWindowAttributes for
- * a change in colormaps.
- *
- * SetNewWindow
- * [Called by: SetValues]
- * [Calls: XGetGeometry]
- * [ GLXwinset]
- * [ XResizeWindow]
- * [ XMapWindow]
- * [ ResizeAux]
- * Used to switch from single/double buffer window to
- * double/single buffer window. Gets information about
- * the current window and sets the same info in the new
- * window.
- *
- * Things that are maintained here:
- * mmode [with all matricies] lsbackup
- * displaymode lsrepeat
- * backface lstyle
- * cmmode pattern
- * color scrmask
- * map sm (shading model)
- * cursor writemask
- * dcm (depthcue) geometry
- * font
- * SetAux
- * [Called by: SetValues]
- * [Calls: SetValuesAux]
- * Used to cal SetValuesAux for each of the overlay,
- * underlay and popup planes.
- *
- * SetValues
- * [Called by: X]
- * [Calls: SetAux]
- * [ XUnmapWindow]
- * [ SetNewWindow]
- * Called to change any resources.
- *
- * RealizeAux
- * [Called by: Realize]
- * [Calls: XCreateWindow]
- * [ XMapWindow]
- * [ XSelectInput]
- * [ _XtRegisterWindow]
- * Used to setup and realize each of the overlay, underlay
- * and/or popup windows.
- *
- * RealizeAuxDup
- * [Called by: RealizeDup]
- * [Calls: XCreateWindow]
- * [ XMapWindow]
- * [ XSelectInput]
- * [ _XtRegisterWindow]
- * Identical to RealizeAux except to be used to set up
- * these windows for the secondary window (single/double
- * buffered window).
- *
- * RealizeDup
- * [Called by: Realize]
- * [Calls: XCreateColormap*]
- * [ XCreateWindow]
- * [ XSelectInput]
- * [ _XtRegisterWindow]
- * [ XSetWMColormapWindows]
- * [ RealizeAuxDup]
- * [ GLXlink]
- * Basically, this is a duplicate of Realize except it
- * sets up the second window.
- *
- * Realize
- * [Called by: X]
- * [Calls: XQueryColors*]
- * [ XtCreateWindow]
- * [ RealizeAux]
- * [ GLXlink]
- * [ RealizeDup]
- * [ GLXwinset]
- * [ XtAddEventHandler]
- * [ XtCallCallbackList]
- * Does all the functions required to actually bring the
- * window up.
- *
- * Redraw
- * [Called by: X]
- *
- * ResizeCallback
- *
- * ResizeAux
- *
- * ResizeDup
- *
- * Resize
- * [Called by: X]
- *
- * Destroy
- * [Called by: X]
- *
- * glxInput
- *
- * auxwindow_destroyed
- *
- * GlxCreateMDraw
- * [Called by: User]
- *
- * * = Commented out
- *------------------------------------------------------------------------*/
-
-
- /*------------------------------------------------------------------------
- * ClassInitialize
- *------------------------------------------------------------------------*/
-
- static void ClassInitialize()
- {
- }
-
- #ifndef USE_GL
- /*------------------------------------------------------------------------
- * Choose an OpenGL visual and create a colormap for it
- *------------------------------------------------------------------------*/
- static void InitializeOpenGLVisual (glw, info, info_overlay)
- GlxDrawWidget glw;
- GlxDrawWindowInfo *info, *info_overlay;
- {
- GlxDrawWindowInfo *curWindowInfo;
- int i;
-
- for(i = 0 ; i < 2 ; i++)
- {
- if(i == 0)
- {
- curWindowInfo = info;
- if(!curWindowInfo->config)
- curWindowInfo->config = default_config;
- }else{
- curWindowInfo = info_overlay;
- }
-
- if(curWindowInfo->config)
- {
- curWindowInfo->exists = TRUE;
- curWindowInfo->visualInfo = glXChooseVisual(XtDisplay (glw),
- XScreenNumberOfScreen (XtScreen (glw)),
- curWindowInfo->config);
- if (!curWindowInfo->visualInfo)
- {
- error(glw, "glXChooseVisual failed");
- return;
- }
- curWindowInfo->colormap = XCreateColormap(XtDisplay (glw),
- RootWindow(XtDisplay (glw),
- curWindowInfo->visualInfo->screen),
- curWindowInfo->visualInfo->visual,
- AllocNone);
- curWindowInfo->depth = curWindowInfo->visualInfo->depth;
- }
- }
- }
- #endif
-
- /*------------------------------------------------------------------------
- * InitializeDup
- * Called to create the second window when both single and double
- * buffered windows are wanted.
- *------------------------------------------------------------------------*/
-
- static void InitializeDup (new, secondary, config)
- GlxDrawWidget new;
- GlxDrawBuffer *secondary;
- #ifdef USE_GL
- GLXconfig *config;
- #else
- int *config;
- #endif /* USE_GL */
- {
- #ifdef USE_GL
- GLXconfig *newConfig, *tmpConfig;
- #else
- int *newConfig, *tmpConfig;
- #endif /* USE_GL */
- GlxDrawWindowInfo *curWindowInfo;
- XVisualInfo tmpl;
- int nret;
-
- /*----
- * Initialize secondary window information
- *----*/
- bzero (&secondary->info, sizeof (GlxDrawWindowInfo));
- curWindowInfo = &secondary->info;
- curWindowInfo->exists = True;
- if (!new->glxDraw.override_colormap)
- curWindowInfo->colormap = new->glxDraw.alt_colormap;
-
- /*----
- * Make a duplicate GLwindow for switch to double
- * buffering
- *----*/
-
- #ifdef USE_GL
- newConfig = GLXgetconfig (XtDisplay (new),
- XScreenNumberOfScreen (XtScreen (new)),
- config);
- if (!newConfig)
- {
- error (new, "Unable to get second visual");
- return;
- }
- secondary->config = newConfig;
-
- for (tmpConfig = newConfig; tmpConfig->buffer; tmpConfig++)
- {
- if (tmpConfig->buffer == GLX_NORMAL)
- {
- switch (tmpConfig->mode)
- {
- case GLX_COLORMAP:
- if (!curWindowInfo->colormap)
- curWindowInfo->colormap = (Colormap)tmpConfig->arg;
- break;
- case GLX_VISUAL:
- tmpl.visualid = tmpConfig->arg;
- tmpl.screen = XScreenNumberOfScreen (XtScreen (new));
- curWindowInfo->visualInfo =
- XGetVisualInfo (XtDisplay(new),
- VisualScreenMask|VisualIDMask,
- &tmpl, &nret);
- if (!curWindowInfo->visualInfo)
- error (new,"Couldn't get visual");
- curWindowInfo->depth =
- curWindowInfo->visualInfo->depth;
- break;
- }
- }
- }
- #else
- secondary->config = config;
- secondary->info.config = config;
- secondary->overlay_info.config = new->glxDraw.overlay_info.config;
- InitializeOpenGLVisual(new, &secondary->info, &secondary->overlay_info );
- #endif /* USE_GL */
- }
-
- /*------------------------------------------------------------------------
- * Initialize
- * Called when widget is created (not mapped). Sets up variables
- * needed and defaults for the resources.
- *
- * Resources set up:
- * core.width (100)
- * core.height (100)
- * core.colormap
- * glxDraw.visualInfo
- * core.depth
- * glxDraw.isRGB
- * glxDraw.{overlay_info & underlay_info & popup_info}.
- * colormap
- * visualInfo
- * depth
- * #ifdef __GLX_MOTIF
- * primitive.highlight_thickness
- * primitive.shadow_thickness
- * #endif
- *
- * If both buffers are requested:
- * glxDraw.single_buffer (TRUE if current window is single buffered)
- * glxDraw.single_buffer_default (TRUE if default window was single)
- *
- * glxDraw.sgl_buf.config
- * glxDraw.sgl_buf.info.colormap
- * glxDraw.sgl_buf.info.visualInfo
- * glxDraw.sgl_buf.info.depth
- *
- * glxDraw.dbl_buf.config
- * glxDraw.dbl_buf.info.colormap
- * glxDraw.dbl_buf.info.visualInfo
- * glxDraw.dbl_buf.info.depth
- *
- * glxDraw.cur_info
- * glxDraw.alt_colormap
- *
- * Variables set up:
- * isDouble (TRUE if default window is double buffered)
- * isStereo (TRUE if default window is stereo buffered)
- *------------------------------------------------------------------------*/
-
- static void Initialize (req, new)
- GlxDrawWidget req, new;
- {
- int isDouble=FALSE;
- int isStereo=FALSE;
- GlxDrawWindowInfo normalWindowInfo;
- GlxDrawWindowInfo *curWindowInfo;
- XVisualInfo tmpl;
- register i;
- int nret;
- #ifdef USE_GL
- GLXconfig *newConfig;
- #else
- int *newConfig;
- #endif
-
- #ifdef DEBUG
- XSynchronize(XtDisplay(new), True);
- #endif
-
- /*----
- * Initialize core elements if they aren't already.
- *----*/
-
- if (req->core.width == 0)
- new->core.width = 100;
- if (req->core.height == 0)
- new->core.height = 100;
-
- /*----
- * Initialize the normalWindowInfo structure. This structure is used
- * to collect all the information about the normal window before it
- * is placed in the widget structure.
- *----*/
-
- bzero (&normalWindowInfo, sizeof (normalWindowInfo));
- normalWindowInfo.exists = TRUE;
-
- /*----
- * By default, we want to override the colormap (we DON'T want to
- * use the core colormap). If the user has reqeusted that we DO
- * want to use a colormap that he has provided, then do it here.
- *----*/
-
- if (!new->glxDraw.override_colormap)
- normalWindowInfo.colormap = new->core.colormap;
-
-
- /*----
- * Get the configuration information that matches what the user
- * requested.
- *
- * If it fails, just return with an error saying that it isn't
- * supported.
- *----*/
-
- #ifdef USE_GL
- newConfig = GLXgetconfig (XtDisplay(new),
- XScreenNumberOfScreen(XtScreen(new)),
- new->glxDraw.config);
- if (!newConfig)
- {
- error(new,"requested visual not supported");
- return;
- }
-
- new->glxDraw.config = newConfig;
- #else
- #endif /* USE_GL */
-
-
- #ifdef USE_GL
- /*------------------------------------------------------------------------
- * Loop through all the entries in the new configuration structure.
- * For each entry:
- * If there is a colormap entry in the configuration structure,
- * put it into the appropriate window info structure.
- * Get the visual info for each of the visuals requested and
- * provided and place it in the appropriate window info
- * structure.
- *------------------------------------------------------------------------*/
-
- new->glxDraw.isRGB = FALSE; /* Default is not RGB mode */
- for (i=0; newConfig[i].buffer; i++)
- {
- switch (newConfig[i].buffer)
- {
- case GLX_NORMAL:
- curWindowInfo = &normalWindowInfo;
- break;
- case GLX_OVERLAY:
- curWindowInfo = &new->glxDraw.overlay_info;
- break;
- case GLX_UNDERLAY:
- curWindowInfo = &new->glxDraw.underlay_info;
- break;
- case GLX_POPUP:
- curWindowInfo = &new->glxDraw.popup_info;
- break;
- }
- if (!curWindowInfo->exists)
- continue;
- switch (newConfig[i].mode)
- {
- case GLX_DOUBLE:
- if ((newConfig[i].buffer == GLX_NORMAL) &&
- new->glxDraw.provide_Sbuffer)
- isDouble = newConfig[i].arg;
- break;
- case GLX_COLORMAP:
- if (!curWindowInfo->colormap)
- curWindowInfo->colormap = (Colormap)newConfig[i].arg;
- break;
- case GLX_VISUAL:
- tmpl.visualid = newConfig[i].arg;
- tmpl.screen = XScreenNumberOfScreen(XtScreen(new));
- curWindowInfo->visualInfo =
- XGetVisualInfo(XtDisplay(new),VisualScreenMask|VisualIDMask,
- &tmpl, &nret);
- if (!curWindowInfo->visualInfo)
- error (new,"Couldn't get visual");
- curWindowInfo->depth = curWindowInfo->visualInfo->depth;
- break;
- case GLX_RGB:
- if(newConfig[i].buffer == GLX_NORMAL)
- new->glxDraw.isRGB = newConfig[i].arg;
- break;
- }
- }
- #else
- /*------------------------------------------------------------------------
- * Choose an OpenGL visual and create a colormap for it
- *------------------------------------------------------------------------*/
- normalWindowInfo.config = new->glxDraw.config;
- InitializeOpenGLVisual(new, &normalWindowInfo, &new->glxDraw.overlay_info);
- #endif /* USE_GL */
-
- /*-----
- * Save visual info for the normal window in the Core widget
- *----*/
- new->core.colormap = normalWindowInfo.colormap;
- new->glxDraw.visualInfo = normalWindowInfo.visualInfo;
- new->core.depth = normalWindowInfo.visualInfo->depth;
-
- #ifdef DEBUG
- #if DEBUG & 0xFFFE
- fprintf (stderr, "GlxDraw: Primary window is %s buffered.\n",
- isDouble ? "double" : "single");
- #endif
- #if DEBUG & 0x0002
- fprintf (stderr, "GlxDraw: Primary window colormap = 0x%08x\n",
- new->core.colormap);
- #endif
- #if DEBUG & 0x0008
- fprintf (stderr, "GlxDraw: Primary window visual ID = %d\n",
- new->glxDraw.visualInfo->visualid);
- fprintf (stderr, " Depth of visual = %d\n",
- new->glxDraw.visualInfo->depth);
- fprintf (stderr, " Colormap size = %d\n",
- new->glxDraw.visualInfo->colormap_size);
- #endif
- #endif
-
- #ifdef __GLX_MOTIF
- /*---
- * Clear any resources that shouldn't be changed by the user.
- * The following resources cannot be changed by the user
- *--*/
-
- new->primitive.highlight_thickness = 0;
- new->primitive.shadow_thickness = 0;
-
- #endif /* __GLX_MOTIF */
-
- /*------------------------------------------------------------------------
- * Here we do the work of making another window if the user requested
- * both a double and single buffer capability.
- *------------------------------------------------------------------------*/
-
- if (new->glxDraw.provide_Sbuffer || new->glxDraw.provide_StereoBuffer) {
- #ifdef USE_GL
- GLXconfig d_config[MAX_CONFIG], s_config[MAX_CONFIG];
- GLXconfig *tmpConfig;
- int di;
-
- /*----
- * Create config structures that are identical to the one
- * provided by the user except that one is single and the
- * other is double.
- *----*/
-
- di = 0;
- nret = 0; /* Flag to say if GLX_DOUBLE found */
- for (i = 0; req->glxDraw.config[i].buffer; i++)
- {
- tmpConfig = &req->glxDraw.config[i];
- d_config[di] = *tmpConfig;
- s_config[di] = *tmpConfig;
- if ((tmpConfig->buffer == GLX_NORMAL) &&
- (tmpConfig->mode == GLX_DOUBLE))
- {
- s_config[di].arg = False;
- d_config[di].arg = True;
- nret = 1;
- }
- if (++di >= MAX_CONFIG)
- {
- error ((Widget)req, "GLXconfig to large to duplicate");
- }
- }
-
- /*----
- * User didn't specify buffering in the config so
- * forceably add entry to set GLX_DOUBLE for single and
- * double buffering. This should never happen.
- *----*/
-
- if (!nret)
- {
- d_config[di].buffer = GLX_NORMAL;
- d_config[di].mode = GLX_DOUBLE;
- d_config[di].arg = True;
- s_config[di].buffer = GLX_NORMAL;
- s_config[di].mode = GLX_DOUBLE;
- s_config[di].arg = False;
- di++;
- }
- d_config[di].buffer = s_config[di].buffer = 0;
- #else
- int d_config[MAX_CONFIG], s_config[MAX_CONFIG];
- int *attrPtr, *singlePtr, *doublePtr;
-
- attrPtr = new->glxDraw.config;
- singlePtr = s_config;
- doublePtr = d_config;
- while(attrPtr < &new->glxDraw.config[MAX_CONFIG])
- {
- switch(*attrPtr)
- {
- case GLX_DOUBLEBUFFER:
- *doublePtr = GLX_DOUBLEBUFFER;
- isDouble = TRUE;
- /* Both buffers are double, one is mono, one is stereo */
- if(!new->glxDraw.provide_Sbuffer)
- {
- *singlePtr = GLX_DOUBLEBUFFER;
- singlePtr++;
- }
- attrPtr++; doublePtr++;
- break;
- case GLX_STEREO:
- *doublePtr = GLX_STEREO;
- isStereo = TRUE;
- /* Both buffers are stereo, one is single, one is double */
- if(!new->glxDraw.provide_StereoBuffer)
- {
- *singlePtr = GLX_STEREO;
- singlePtr++;
- }
- attrPtr++; doublePtr++;
- break;
- case GLX_RGBA:
- new->glxDraw.isRGB = TRUE;
- *doublePtr = *attrPtr;
- *singlePtr = *attrPtr;
- attrPtr++; doublePtr++; singlePtr++;
- break;
- case GLX_USE_GL:
- *doublePtr = *attrPtr;
- *singlePtr = *attrPtr;
- attrPtr++; doublePtr++; singlePtr++;
- break;
- case GLX_BUFFER_SIZE:
- case GLX_LEVEL:
- case GLX_AUX_BUFFERS:
- case GLX_RED_SIZE:
- case GLX_GREEN_SIZE:
- case GLX_BLUE_SIZE:
- case GLX_ALPHA_SIZE:
- case GLX_DEPTH_SIZE:
- case GLX_STENCIL_SIZE:
- case GLX_ACCUM_RED_SIZE:
- case GLX_ACCUM_GREEN_SIZE:
- case GLX_ACCUM_BLUE_SIZE:
- case GLX_ACCUM_ALPHA_SIZE:
- *doublePtr = *attrPtr;
- *singlePtr = *attrPtr;
- attrPtr++; doublePtr++; singlePtr++;
- *doublePtr = *attrPtr;
- *singlePtr = *attrPtr;
- attrPtr++; doublePtr++; singlePtr++;
- break;
- case None:
- if(!isDouble && new->glxDraw.provide_Sbuffer)
- {
- *doublePtr = GLX_DOUBLEBUFFER; doublePtr++;
- }
- if(!isStereo && new->glxDraw.provide_StereoBuffer)
- {
- *doublePtr = GLX_STEREO; doublePtr++;
- }
- *doublePtr = *attrPtr;
- *singlePtr = *attrPtr;
- attrPtr = &new->glxDraw.config[MAX_CONFIG];
- break;
- default:
- error(new, "Invalid attribute in GLXConfig");
- return;
- }
- }
- #endif /* USE_GL */
-
- /*----
- * Setup another window to allow switch to double buffering
- * Depending on which type of window has already been
- * requested, we request the other.
- *----*/
-
- if (!isDouble || !isStereo) /* Default window was SINGLE BUFFERED */
- {
- new->glxDraw.single_buffer = TRUE;
- new->glxDraw.single_buffer_default = TRUE;
-
- /*----
- * Copy currently created window config and info to
- * single buffer structures
- *----*/
-
- new->glxDraw.sgl_buf.config = newConfig;
- memcpy(&new->glxDraw.sgl_buf.info, &normalWindowInfo,
- (size_t)sizeof(normalWindowInfo));
- new->glxDraw.cur_info = &new->glxDraw.sgl_buf.info;
-
- InitializeDup (new, &new->glxDraw.dbl_buf, d_config);
-
- new->glxDraw.alt_colormap = new->glxDraw.dbl_buf.info.colormap;
- #ifdef DEBUG
- #if DEBUG & 0x0008
- fprintf (stderr, "GlxDraw: Secondary window visual ID = %d\n",
- new->glxDraw.dbl_buf.info.visualInfo->visualid);
- fprintf (stderr, " Depth of visual = %d\n",
- new->glxDraw.dbl_buf.info.visualInfo->depth);
- fprintf (stderr, " Colormap size = %d\n",
- new->glxDraw.dbl_buf.info.visualInfo->colormap_size);
- #endif
- #endif
- }
-
- /*----
- * Setup another window to allow switch to single buffering
- * Default is double buffered
- *----*/
-
- else /* Default window was DOUBLE BUFFERED */
- {
- new->glxDraw.single_buffer = FALSE;
- new->glxDraw.single_buffer_default = FALSE;
-
- /*----
- * Copy default window config and info to double
- * buffer structures
- *----*/
-
- new->glxDraw.dbl_buf.config = newConfig;
- memcpy(&new->glxDraw.dbl_buf.info, &normalWindowInfo,
- (size_t)sizeof(normalWindowInfo));
- new->glxDraw.cur_info = &new->glxDraw.dbl_buf.info;
-
- InitializeDup (new, &new->glxDraw.sgl_buf, s_config);
-
- new->glxDraw.alt_colormap = new->glxDraw.sgl_buf.info.colormap;
- #ifdef DEBUG
- #if DEBUG & 0x0008
- fprintf (stderr, "GlxDraw: Secondary window visual ID = %d\n",
- new->glxDraw.sgl_buf.info.visualInfo->visualid);
- fprintf (stderr, " Depth of visual = %d\n",
- new->glxDraw.sgl_buf.info.visualInfo->depth);
- fprintf (stderr, " Colormap size = %d\n",
- new->glxDraw.sgl_buf.info.visualInfo->colormap_size);
- #endif
- #endif
- }
- #ifdef DEBUG
- #if DEBUG & 0x0002
- fprintf (stderr, "GlxDraw: Secondary window colormap = 0x%08x\n",
- new->glxDraw.alt_colormap);
- #endif
- #endif
- }
- }
-
- /*------------------------------------------------------------------------
- * SetValuesAux
- * Set values portion for the auxiliaries
- *------------------------------------------------------------------------*/
-
- static void SetValuesAux (w, current, request, new)
- Widget w; /* for obtaining the display */
- GlxDrawWindowInfo *current, *request, *new;
- {
- XSetWindowAttributes attributes;
-
- /* Changing the following after create time will harm me */
- new->exists = current->exists;
- new->window = current->window;
- new->depth = current->depth;
- new->visualInfo = current->visualInfo;
-
- #ifdef DEBUG
- #if DEBUG & 0x0004
- if (new->exists)
- fprintf (stderr, "GlxDraw: Changing values for window 0x%08x\n",
- new->window);
- #endif
- #if DEBUG & 0x0008
- if (new->exists)
- fprintf (stderr, "GlxDraw: Changing visual for window 0x%08x to %d\n",
- new->window, new->visualInfo->visualid);
- #endif
- #endif
-
- /* if the colormap has changed, and the window has been
- * created, change the colormap on the window */
- if (current->colormap != new->colormap && new->window)
- {
- attributes.colormap = new->colormap;
- XChangeWindowAttributes(
- XtDisplay(w), new->window, CWColormap, &attributes);
- #ifdef DEBUG
- #if DEBUG & 0x0002
- if (new->exists)
- fprintf(stderr,
- "GlxDraw: Changing colormap for window 0x%08x to 0x%08x\n",
- new->window, new->colormap);
- #endif
- #endif
- }
- }
-
-
- static void ResizeAux();
-
- /*------------------------------------------------------------------------
- * SetNewWindow
- *------------------------------------------------------------------------*/
-
- static void SetNewWindow(new, newBuffer, oldBuffer)
- GlxDrawWidget new;
- GlxDrawBuffer *newBuffer;
- GlxDrawBuffer *oldBuffer;
- {
- Window root;
- int x,y;
- unsigned int width, height, border_width, depth;
-
- #ifdef USE_GL
- Matrix mSingle;
- Matrix mProjection;
- Matrix mViewing;
- Matrix mTexture;
- long mode;
-
- long backFace;
- Boolean cmMode;
- short cposX, cposY;
- long curColor;
- short cursor;
- unsigned short usdum;
- unsigned char ucdum;
- long ldum;
- Boolean depthCue;
- long drawMode;
- long displayMode;
- long fontNumber;
- Coord curX, curY, curZ, curW;
- long gethitcode;
- Boolean lineSBackup;
- long lineSRepeat;
- long lineSReset;
- long lineStyle;
- long lineWidth;
- long colorMap;
- long pattern;
- Screencoord left,right,top,bottom;
- long shadingModel;
- long writeMask;
- #else
- GLfloat modelViewMatrix[16];
- GLfloat projectionMatrix[16];
- GLint viewPort[4];
- GLfloat modelViewMatrixOverlay[16];
- GLfloat projectionMatrixOverlay[16];
- GLint viewPortOverlay[4];
- #endif /* USE_GL */
-
- new->glxDraw.cur_info = &newBuffer->info;
- new->core.window = newBuffer->info.window;
- #ifndef USE_GL
- new->glxDraw.context = newBuffer->info.context;
- #endif
- new->glxDraw.visualInfo = newBuffer->info.visualInfo;
- new->glxDraw.overlay_info = newBuffer->overlay_info;
- new->glxDraw.underlay_info = newBuffer->underlay_info;
- new->glxDraw.popup_info = newBuffer->popup_info;
-
-
- /* Get all possible attributes from old window */
- #ifdef USE_GL
- mode = getmmode();
- if(mode == MSINGLE)
- {
- mmode(MSINGLE);
- getmatrix(mSingle);
- }else{
- mmode(MPROJECTION);
- getmatrix(mProjection);
- mmode(MVIEWING);
- getmatrix(mViewing);
- mmode(MTEXTURE);
- getmatrix(mTexture);
- mmode(mode);
- }
-
- displayMode = getdisplaymode();
-
- backFace = getbackface();
- if(displayMode == DMSINGLE || displayMode == DMDOUBLE)
- {
- cmMode = getcmmode();
- curColor = getcolor();
- colorMap = getmap();
- }
- getcursor (&cursor, &usdum, &usdum, &ldum);
- /* getcpos (&cposX, &cposY);*/
- depthCue = getdcm();
- /* drawMode = getdrawmode();*/
- fontNumber = getfont();
- /* getgpos (&curX, &curY, &curZ, &curW);*/
- /* hitCode = gethitcode;*/
- lineSBackup = getlsbackup();
- lineSRepeat = getlsrepeat();
- /* lineSReset = getresetls();*/
- lineStyle = getlstyle();
- /* lineWidth = getlwidth();*/
- pattern = getpattern();
- getscrmask(&left, &right, &bottom, &top);
- shadingModel = getsm();
- writeMask = getwritemask();
- #else
- glXMakeCurrent(XtDisplay (new), oldBuffer->info.window,
- oldBuffer->info.context);
- glGetFloatv(GL_MODELVIEW_MATRIX, modelViewMatrix);
- glGetFloatv(GL_PROJECTION_MATRIX, projectionMatrix);
- glGetIntegerv(GL_VIEWPORT, viewPort);
- if(oldBuffer->overlay_info.exists)
- {
- glXMakeCurrent(XtDisplay (new), oldBuffer->overlay_info.window,
- oldBuffer->overlay_info.context);
- glGetFloatv(GL_MODELVIEW_MATRIX, modelViewMatrixOverlay);
- glGetFloatv(GL_PROJECTION_MATRIX, projectionMatrixOverlay);
- glGetIntegerv(GL_VIEWPORT, viewPortOverlay);
- }
- #endif /* USE_GL */
-
- /* Get geometry of old window, then resize the new one to match */
- if(!XGetGeometry(XtDisplay (new), oldBuffer->info.window,
- &root, &x, &y, &width, &height,
- &border_width, &depth))
- warning ((Widget)new, "SetNewWindow : XGetGeometry failed");
-
- /* Map new window for X */
- XMapRaised (XtDisplay (new), newBuffer->info.window);
-
- #ifdef DEBUG
- #if DEBUG & 0x0004
- fprintf (stderr, "GlxDraw: Changing GLX window to 0x%08x\n",
- newBuffer->info.window);
- #endif
- #endif
-
- /* Set new window for GL */
- #ifdef USE_GL
- GLXwinset (XtDisplay (new), newBuffer->info.window);
-
- XResizeWindow(XtDisplay (new), newBuffer->info.window,
- width, height);
-
- viewport(0, (Screencoord) width-1, 0, (Screencoord) height-1);
-
- ResizeAux(new, &newBuffer->overlay_info,
- &newBuffer->underlay_info,
- &newBuffer->popup_info);
- /* What kind of display mode am i really in */
- displayMode = getdisplaymode();
-
- /* Set old windows attributes on the new window */
- if(mode == MSINGLE)
- {
- mmode(MSINGLE);
- loadmatrix(mSingle);
- }else{
- mmode(MPROJECTION);
- loadmatrix(mProjection);
- mmode(MVIEWING);
- loadmatrix(mViewing);
- mmode(MTEXTURE);
- loadmatrix(mTexture);
- }
- mmode(mode);
-
- backface(backFace);
- setcursor(cursor, usdum, usdum);
- if(displayMode == DMSINGLE || displayMode == DMDOUBLE)
- {
- color(curColor);
- if(cmMode)
- onemap();
- else{
- multimap();
- setmap(colorMap);
- }
- }
- depthcue(depthCue);
- font(fontNumber);
- lsbackup(lineSBackup);
- lsrepeat(lineSRepeat);
- setpattern(pattern);
- shademodel(shadingModel);
- #else
- /*
- * Make the new overlay window like the old one where possible if there is one
- */
- if(newBuffer->overlay_info.exists)
- {
- glXMakeCurrent(XtDisplay (new), newBuffer->overlay_info.window,
- newBuffer->overlay_info.context);
-
- glViewport(viewPortOverlay[0], viewPortOverlay[1],
- viewPortOverlay[2], viewPortOverlay[3]);
-
- ResizeAux(new, &newBuffer->overlay_info,
- &newBuffer->underlay_info,
- &newBuffer->popup_info);
-
- glMatrixMode(GL_PROJECTION);
- glLoadMatrixf(projectionMatrix);
- glMatrixMode(GL_MODELVIEW);
- glLoadMatrixf(modelViewMatrix);
- }
- /*
- * Make the new normal window like the old one where possible
- */
- glXMakeCurrent(XtDisplay (new), newBuffer->info.window,
- newBuffer->info.context);
-
- XResizeWindow(XtDisplay (new), newBuffer->info.window,
- width, height);
-
- glViewport(viewPort[0], viewPort[1], viewPort[2], viewPort[3]);
-
- glMatrixMode(GL_PROJECTION);
- glLoadMatrixf(projectionMatrix);
- glMatrixMode(GL_MODELVIEW);
- glLoadMatrixf(modelViewMatrix);
- #endif /* USE_GL */
- }
-
- /*------------------------------------------------------------------------
- * SetAux Handle requests to change resources in aux windows.
- *------------------------------------------------------------------------*/
- static void SetAux (current, request, new)
- GlxDrawWidget current, request, new;
- {
- SetValuesAux(new,
- ¤t->glxDraw.overlay_info,
- &request->glxDraw.overlay_info,
- &new->glxDraw.overlay_info);
- SetValuesAux(new,
- ¤t->glxDraw.underlay_info,
- &request->glxDraw.underlay_info,
- &new->glxDraw.underlay_info);
- SetValuesAux(new,
- ¤t->glxDraw.popup_info,
- &request->glxDraw.popup_info,
- &new->glxDraw.popup_info);
- }
-
-
- /*------------------------------------------------------------------------
- * SetValues Handle requests to change resources.
- *
- * Returns:
- * True Xlib must call XClearArea and the <expose> callbacks.
- * False No redrawing is required.
- *------------------------------------------------------------------------*/
- static Boolean SetValues (current, request, new)
- GlxDrawWidget current, request, new;
- {
- SetAux(current, request, new);
-
- #ifdef __GLX_MOTIF
- /* The following resources cannot be changed by the user */
- new->primitive.highlight_thickness = 0;
- new->primitive.shadow_thickness = 0;
- #endif /* __GLX_MOTIF */
-
- /*----
- * If setting to single buffer mode from double buffer mode.
- *----*/
- if (new->glxDraw.single_buffer) {
- if (!current->glxDraw.single_buffer) {
- if(current->glxDraw.single_buffer_default)
- XUnmapWindow(XtDisplay(new), current->glxDraw.dbl_buf.info.window);
- SetNewWindow(new, &new->glxDraw.sgl_buf, &new->glxDraw.dbl_buf);
- return(True); /* Force an expose/redraw */
- }
-
- /*----
- * If setting to double buffer mode from single buffer mode.
- *----*/
- } else if (current->glxDraw.single_buffer) {
- if(!current->glxDraw.single_buffer_default)
- XUnmapWindow (XtDisplay(new), current->glxDraw.sgl_buf.info.window);
- SetNewWindow(new, &new->glxDraw.dbl_buf, &new->glxDraw.sgl_buf);
- #ifndef USE_GL
- glDrawBuffer(GL_BACK);
- #endif
- return(True); /* Force an expose/redraw */
- }
- return (False); /* No expose/redraw */
- }
-
- /*------------------------------------------------------------------------
- * RealizeAux
- * Called to create overlay, underlay and/or popup windows.
- *
- * Resources set up:
- * glxDraw.overlay_info.window
- * glxDraw.underlay_info.window
- * glxDraw.popup_info.window
- *------------------------------------------------------------------------*/
-
- static void RealizeAux (glw, aux_info, parent)
- register GlxDrawWidget glw;
- register GlxDrawWindowInfo *aux_info;
- Window parent;
- {
- XSetWindowAttributes aux_attributes;
-
- aux_attributes.colormap = aux_info->colormap;
- aux_attributes.border_pixel = 0;
- aux_info->window =
- XCreateWindow(XtDisplay(glw), parent, 0, 0,
- glw->core.width, glw->core.height, 0,
- aux_info->depth, InputOutput,
- aux_info->visualInfo->visual,
- CWColormap|CWBorderPixel, &aux_attributes);
- XMapWindow(XtDisplay(glw),aux_info->window);
-
- /*
- * We explicitly need the exposure events for this window
- */
-
- XSelectInput(XtDisplay(glw), aux_info->window, ExposureMask);
-
- /* Tell Xt to tell us about the exposure events
- * Note that this is a private Xt routine that may change in the
- * future, but it is the only way to get the exposure events. This
- * code may need to change in the future
- */
-
- _XtRegisterWindow(aux_info->window,glw);
-
- #ifdef DEBUG
- #if DEBUG & 0x0004
- fprintf (stderr, " Window created = 0x%08x\n", aux_info->window);
- #endif
- #endif
- }
-
- /*------------------------------------------------------------------------
- * RealizeDup
- * Duplicate of Realize except for secondary window.
- *------------------------------------------------------------------------*/
-
- static int RealizeDup(glw, primary, secondary, valueMask, attributes)
- GlxDrawWidget glw;
- GlxDrawBuffer *primary;
- GlxDrawBuffer *secondary;
- Mask *valueMask;
- XSetWindowAttributes *attributes;
- {
- GlxDrawWindowInfo *info;
- #ifdef USE_GL
- register GLXconfig *glp;
- #else
- #endif /* USE_GL */
- Window windows[2];
- int cmapAlloc;
- int has_aux=FALSE;
- int i;
- int stat;
-
- glw->glxDraw.mainWindow = primary->info.window;
-
- info = &secondary->info;
- /*
- * You must allocate and set a new colormap if the secondary window
- * visual doesn't match the primary (Usually the case when
- * using this feature, sincde depth in single is greater than double)
- *
- * Note the secondary window depth must always be less than the parent
- *
- */
- if(glw->glxDraw.visualInfo->depth != info->depth)
- {
- if(glw->glxDraw.visualInfo->depth < info->depth)
- {
- error ((Widget)glw,
- "Fatal error: Child depth greater than parent\n");
- }
- }
- /*
- * Create an X window for secondary buffer. Not mapped yet. It will be
- * rolled in when appropriate set values is done.
- */
-
- attributes->colormap = info->colormap;
- *valueMask |= CWColormap;
- info->window = XCreateWindow (XtDisplay(glw),
- XtWindow(glw),
- 0, 0,
- glw->core.width, glw->core.height, 0,
- info->depth, InputOutput,
- info->visualInfo->visual,
- *valueMask, attributes);
-
- #ifdef ORIGINAL
- /* this is not needed, and breaks input on 5.1 */
- XSelectInput (XtDisplay (glw), info->window, ExposureMask);
- #endif
- _XtRegisterWindow (info->window, glw);
-
- #ifdef DEBUG
- #if DEBUG & 0x0004
- fprintf (stderr, "GlxDraw: Secondary window is 0x%08x\n", info->window);
- #endif
- #endif
-
- /*
- * Special case for Indigo Starter which uses a PsuedoColor visual
- * for RGB mode. Requires building my own color map
- *
- * Tell window manager I have a special color map
- */
- if(glw->glxDraw.isRGB
- && info->visualInfo->class == PseudoColor)
- {
- windows[0] = info->window;
- stat = XSetWMColormapWindows(XtDisplay(glw),
- XtWindow(glw),
- windows,
- 1);
- if(!stat)
- warning ((Widget)glw, "XSetWMColormapWindows failed\n");
- }
-
- /*
- * Copy default auxiliary info to structures for primary and
- * secondary buffers
- */
- primary->overlay_info = glw->glxDraw.overlay_info;
- primary->underlay_info = glw->glxDraw.underlay_info;
- primary->popup_info = glw->glxDraw.popup_info;
- #ifndef USE_GL
- primary->info.context = glw->glxDraw.context;
- #endif
-
- secondary->overlay_info = glw->glxDraw.overlay_info;
- secondary->underlay_info = glw->glxDraw.underlay_info;
- secondary->popup_info = glw->glxDraw.popup_info;
-
- /*
- * Duplicate auxiliary windows, if necessary, for secondary buffer
- */
- if (glw->glxDraw.overlay_info.exists) {
- has_aux = TRUE;
- #ifdef DEBUG
- #if DEBUG & 0x0004
- fprintf (stderr, "GlxDraw: Creating secondary overlay window\n");
- #endif
- #endif
- RealizeAux (glw,&secondary->overlay_info, info->window);
- }
- if (glw->glxDraw.underlay_info.exists) {
- has_aux = TRUE;
- #ifdef DEBUG
- #if DEBUG & 0x0004
- fprintf (stderr, "GlxDraw: Creating secondary underlay window\n");
- #endif
- #endif
- RealizeAux (glw,&secondary->underlay_info, info->window);
- }
- if (glw->glxDraw.popup_info.exists) {
- has_aux = TRUE;
- #ifdef DEBUG
- #if DEBUG & 0x0004
- fprintf (stderr, "GlxDraw: Creating secondary popup window\n");
- #endif
- #endif
- RealizeAux (glw,&secondary->popup_info, info->window);
- }
-
- #ifdef USE_GL
- /*
- * Store windows in appropriate places in config structure for GLXlink
- */
- for (glp = secondary->config; glp->buffer; glp++) {
- if (glp->mode == GLX_WINDOW) {
- switch (glp->buffer) {
- case GLX_NORMAL:
- glp->arg = info->window;
- break;
- case GLX_OVERLAY:
- if (secondary->overlay_info.exists)
- glp->arg = secondary->overlay_info.window;
- break;
- case GLX_UNDERLAY:
- if (secondary->underlay_info.exists)
- glp->arg = secondary->underlay_info.window;
- break;
- case GLX_POPUP:
- if (secondary->popup_info.exists)
- glp->arg = secondary->popup_info.window;
- break;
- }
- }
- }
-
-
-
- /* Link the secondary window for GL */
- i = GLXlink (XtDisplay (glw), secondary->config);
- if (i < 0)
- error (glw, gl_errs[-i]);
- #else
- /* Create an OpenGL context on the X window */
- info->context = glXCreateContext(XtDisplay(glw),
- info->visualInfo, 0, GL_TRUE);
- if(!info->context){
- error("OpenGL not supported on this display");
- return;
- }
-
- if(secondary->overlay_info.exists)
- {
- secondary->overlay_info.context = glXCreateContext(XtDisplay(glw),
- secondary->overlay_info.visualInfo,
- 0, GL_TRUE);
- if(!secondary->overlay_info.context){
- error("OpenGL overlay not supported on this display");
- return;
- }
- }
- #endif /* USE_GL */
-
-
- glw->glxDraw.visualInfo = primary->info.visualInfo;
-
- return(has_aux);
- }
-
- /*------------------------------------------------------------------------
- * Realize
- * Called when widget is to be mapped. Does final loading of
- * resources. Maps all subwindows (overlay, underlay and popup).
- *
- * Resources set up:
- * glxDraw.config [GLX_NORMAL & GLX_WINDOW]
- * glxDraw.config [GLX_OVERLAY & GLX_WINDOW]
- * glxDraw.config [GLX_UNDERLAY & GLX_WINDOW]
- * glxDraw.config [GLX_POPUP & GLX_WINDOW]
- * glxDraw.mainWindow
- * glxDraw.cur_info->window
- *------------------------------------------------------------------------*/
-
- static void Realize(w, valueMask, attributes)
- Widget w;
- Mask *valueMask;
- XSetWindowAttributes *attributes;
- {
- register GlxDrawWidget glw = (GlxDrawWidget)w;
- Boolean has_aux=FALSE;
- GlxDrawCallbackStruct cb;
- #ifdef USE_GL
- register GLXconfig *glp;
- #endif /* USE_GL */
- XColor colorDefs[256];
- int i;
-
- /* Since GL programs are expected to clear the screen themselves,
- * we don't want X to clear the screen, so don't set the background
- * pixel.
- */
- *valueMask &= ~CWBackPixel;
-
- XtCreateWindow (w, (unsigned int)InputOutput,
- glw->glxDraw.visualInfo->visual,
- *valueMask, attributes);
-
- #ifdef DEBUG
- #if DEBUG & 0x0004
- fprintf (stderr, "GlxDraw: Primary window is 0x%08x\n", XtWindow (glw));
- #endif
- #endif
-
- if (glw->glxDraw.overlay_info.exists) {
- has_aux = TRUE;
- #ifdef DEBUG
- #if DEBUG & 0x0004
- fprintf (stderr, "GlxDraw: Creating primary overlay window\n");
- #endif
- #endif
- RealizeAux (glw,&glw->glxDraw.overlay_info, XtWindow (glw));
- }
- if (glw->glxDraw.underlay_info.exists) {
- has_aux = TRUE;
- #ifdef DEBUG
- #if DEBUG & 0x0004
- fprintf (stderr, "GlxDraw: Creating primary underlay window\n");
- #endif
- #endif
- RealizeAux (glw,&glw->glxDraw.underlay_info, XtWindow (glw));
- }
- if (glw->glxDraw.popup_info.exists) {
- has_aux = TRUE;
- #ifdef DEBUG
- #if DEBUG & 0x0004
- fprintf (stderr, "GlxDraw: Creating primary popup window\n");
- #endif
- #endif
- RealizeAux (glw,&glw->glxDraw.popup_info, XtWindow (glw));
- }
-
- /*----
- * Now go through all the GLXconfig structures and fill
- * in the GLX_WINDOW argument for each type of window.
- *----*/
-
- #ifdef USE_GL
- for (glp = glw->glxDraw.config; glp->buffer; glp++) {
- if (glp->mode == GLX_WINDOW) {
- switch (glp->buffer) {
- case GLX_NORMAL:
- glp->arg = XtWindow(glw);
- glw->glxDraw.mainWindow = XtWindow (glw);
- break;
- case GLX_OVERLAY:
- if (glw->glxDraw.overlay_info.exists)
- glp->arg = glw->glxDraw.overlay_info.window;
- break;
- case GLX_UNDERLAY:
- if (glw->glxDraw.underlay_info.exists)
- glp->arg = glw->glxDraw.underlay_info.window;
- break;
- case GLX_POPUP:
- if (glw->glxDraw.popup_info.exists)
- glp->arg = glw->glxDraw.popup_info.window;
- break;
- }
- }
- }
-
- i = GLXlink(XtDisplay(w), glw->glxDraw.config);
- if (i < 0)
- error (glw, gl_errs[-i]);
- #else
- /* Create an OpenGL context on the X window */
- glw->glxDraw.context = glXCreateContext(XtDisplay(w),
- glw->glxDraw.visualInfo, 0, GL_TRUE);
- if(!glw->glxDraw.context){
- error("OpenGL not supported on this display");
- return;
- }
-
- /* Make the OpenGL context we just created the current one */
- if (!glXMakeCurrent(XtDisplay(w), XtWindow(w), glw->glxDraw.context)) {
- error("Can't make window current to OpenGL context\n");
- return;
- }
-
- if (glw->glxDraw.overlay_info.exists)
- {
- glw->glxDraw.overlay_info.context = glXCreateContext(XtDisplay(w),
- glw->glxDraw.overlay_info.visualInfo,
- 0, GL_TRUE);
- if(!glw->glxDraw.overlay_info.context){
- error("OpenGL overlay not supported on this display");
- return;
- }
- }
- #endif /* USE_GL */
-
- /*
- * If provide_Sbuffer is set then allow switching between single and double
- * buffering. Requires creation of a secondary window which is used
- * for alternate mode. If main window is double buffered then secondary
- * window is single buffered and vice versa.
- *
- * Underlay, overlay and popups are also duplicated with secondary window
- * as the parent
- */
-
- if (glw->glxDraw.provide_Sbuffer || glw->glxDraw.provide_StereoBuffer) {
- GlxDrawWindowInfo *curWindowInfo;
- int i;
- /*
- * Set window for the default window in current info structure
- */
-
- glw->glxDraw.cur_info->window = XtWindow (glw);
-
-
- /*
- * Make auxiliary window to allow switch to double buffering
- */
- if(glw->glxDraw.single_buffer_default)
- {
- RealizeDup(glw, &glw->glxDraw.sgl_buf.info,
- &glw->glxDraw.dbl_buf.info,
- valueMask,
- attributes);
- /*
- * or else make auxiliary window to allow switch to single buffering
- */
- }
- else
- {
- RealizeDup(glw, &glw->glxDraw.dbl_buf.info,
- &glw->glxDraw.sgl_buf.info,
- valueMask,
- attributes);
- }
- }
- /* Be a nice guy and do one GLXwinset on the main window. This avoids
- * the need to do GLXwinsets in programs with only one window.
- */
-
- #ifdef USE_GL
- GLXwinset(XtDisplay(w), XtWindow(w));
-
- if(glw->glxDraw.isRGB)
- cpack(0);
- else
- color(0);
- clear();
- #else
- glXMakeCurrent(XtDisplay (w), XtWindow(w), glw->glxDraw.context);
- #endif /* USE_GL */
-
- /* If there is an overlay or an underlay, we need to be notified if it
- * is destroyed */
- if (has_aux)
- XtAddEventHandler((Widget) glw, SubstructureNotifyMask, FALSE,
- auxwindow_destroyed, NULL);
-
- cb.reason = GlxCR_GINIT;
- cb.event = NULL;
- cb.window = XtWindow(glw);
- cb.width = glw->core.width;
- cb.height = glw->core.height;
- #ifndef USE_GL
- cb.context = glw->glxDraw.context;
- #endif
- XtCallCallbackList((Widget) glw, glw->glxDraw.ginit_callback, &cb);
- }
-
- /*------------------------------------------------------------------------
- * Redraw
- *------------------------------------------------------------------------*/
-
- static void Redraw (glw, event, region)
- GlxDrawWidget glw;
- XEvent *event;
- Region region;
- {
- GlxDrawCallbackStruct cb;
- XtCallbackList cblist;
-
- cb.reason = GlxCR_EXPOSE;
- cb.event = event;
- cb.window = event->xexpose.window;
- cb.width = glw->core.width;
- cb.height = glw->core.height;
- if (cb.window == XtWindow(glw))
- {
- #ifdef USE_GL
- cb.buffer = GLX_NORMAL;
- #else
- cb.context = glw->glxDraw.context;
- #endif /* USE_GL */
- cblist = glw->glxDraw.expose_callback;
- }
- else if (cb.window == glw->glxDraw.dbl_buf.info.window) {
- #ifdef USE_GL
- cb.buffer = GLX_NORMAL;
- #else
- cb.context = glw->glxDraw.dbl_buf.info.context;
- #endif /* USE_GL */
- cblist = glw->glxDraw.expose_callback;
- }
- else if (cb.window == glw->glxDraw.sgl_buf.info.window) {
- #ifdef USE_GL
- cb.buffer = GLX_NORMAL;
- #else
- cb.context = glw->glxDraw.sgl_buf.info.context;
- #endif /* USE_GL */
- cblist = glw->glxDraw.expose_callback;
- }
- else if (cb.window == glw->glxDraw.overlay_info.window)
- {
- #ifdef USE_GL
- cb.buffer = GLX_OVERLAY;
- #else
- cb.context = glw->glxDraw.overlay_info.context;
- #endif /* USE_GL */
- cblist = glw->glxDraw.overlay_info.expose_callback;
- }
- else if (cb.window == glw->glxDraw.underlay_info.window)
- {
- #ifdef USE_GL
- cb.buffer = GLX_UNDERLAY;
- #else
- cblist = glw->glxDraw.underlay_info.expose_callback;
- #endif /* USE_GL */
- cblist = glw->glxDraw.underlay_info.expose_callback;
- }
- else if (cb.window == glw->glxDraw.popup_info.window)
- {
- #ifdef USE_GL
- cb.buffer = GLX_POPUP;
- #else
- cblist = glw->glxDraw.popup_info.expose_callback;
- #endif /* USE_GL */
- cblist = glw->glxDraw.popup_info.expose_callback;
- }
- else
- {
- /*
- * Probably a redraw on an inactive secondary window
- * Usually from resize, since we have to have resize events to all windows
- * but we don't want redraw on inactive windows
- */
- return;
- }
- XtCallCallbackList ((Widget) glw, cblist, &cb);
- }
-
- /*------------------------------------------------------------------------
- * ResizeCallback
- *------------------------------------------------------------------------*/
-
- static void ResizeCallback(glw, window)
- GlxDrawWidget glw;
- Window window;
- {
- GlxDrawCallbackStruct cb;
-
- cb.reason = GlxCR_RESIZE;
- cb.event = NULL;
- cb.window = window;
- cb.width = glw->core.width;
- cb.height = glw->core.height;
- #ifdef USE_GL
- cb.buffer = GLX_NORMAL;
- #else
- cb.context = glw->glxDraw.context;
- #endif /* USE_GL */
- /* The following XSync fixes a bug whereby viewport can fail.
- * On Indigo, viewport queries the size of the X window
- * and gets the old size without this Xsync.
- */
- XSync(XtDisplay(glw),FALSE);
- XtCallCallbackList ((Widget) glw, glw->glxDraw.resize_callback, &cb);
- }
-
- /*------------------------------------------------------------------------
- * ResizeAux
- *------------------------------------------------------------------------*/
-
- static void ResizeAux(glw, overlay_info, underlay_info, popup_info)
- GlxDrawWidget glw;
- GlxDrawWindowInfo *overlay_info, *underlay_info, *popup_info;
- {
- if (overlay_info->exists && overlay_info->window)
- XResizeWindow(XtDisplay(glw), overlay_info->window,
- glw->core.width, glw->core.height);
- if (underlay_info->exists && underlay_info->window)
- XResizeWindow(XtDisplay(glw), underlay_info->window,
- glw->core.width, glw->core.height);
- if (popup_info->exists && popup_info->window)
- XResizeWindow(XtDisplay(glw), popup_info->window,
- glw->core.width, glw->core.height);
- }
-
- /*------------------------------------------------------------------------
- * ResizeDup
- *------------------------------------------------------------------------*/
-
- static void ResizeDup(glw)
- GlxDrawWidget glw;
- {
- /*
- * Resize inactive main, overlay, underlay and popup windows if necessary
- */
- /* Single is current so resize double */
- if (glw->glxDraw.single_buffer)
- {
- XResizeWindow(XtDisplay(glw), glw->glxDraw.dbl_buf.info.window,
- glw->core.width, glw->core.height);
- ResizeAux(glw, &glw->glxDraw.dbl_buf.overlay_info,
- &glw->glxDraw.dbl_buf.underlay_info,
- &glw->glxDraw.dbl_buf.popup_info);
- ResizeCallback(glw, glw->glxDraw.dbl_buf.info.window);
- /* Double is current so resize single */
- }else{
- XResizeWindow(XtDisplay(glw), glw->glxDraw.sgl_buf.info.window,
- glw->core.width, glw->core.height);
- ResizeAux(glw, &glw->glxDraw.sgl_buf.overlay_info,
- &glw->glxDraw.sgl_buf.underlay_info,
- &glw->glxDraw.sgl_buf.popup_info);
- ResizeCallback(glw, glw->glxDraw.sgl_buf.info.window);
- }
- }
-
- /*------------------------------------------------------------------------
- * Resize
- *------------------------------------------------------------------------*/
-
- static void Resize(glw)
- GlxDrawWidget glw;
- {
-
- /* if we get a resize event before being realized, we can't handle it */
- if (!XtIsRealized((Widget)glw))
- return;
-
- /* Resize current overlay, underlay and popup planes if necessary */
- ResizeAux(glw, &glw->glxDraw.overlay_info,
- &glw->glxDraw.underlay_info,
- &glw->glxDraw.popup_info);
-
- if (glw->glxDraw.provide_Sbuffer || glw->glxDraw.provide_StereoBuffer)
- {
- /* Resize secondary window */
- ResizeDup(glw);
-
- /* Resize callback for current window */
- ResizeCallback(glw, XtWindow((Widget) glw));
- }else
- ResizeCallback(glw, XtWindow((Widget) glw));
- }
-
- /*------------------------------------------------------------------------
- * Destroy
- *------------------------------------------------------------------------*/
-
- static void Destroy(glw)
- GlxDrawWidget glw;
- {
- #ifdef USE_GL
- XtFree((char *)glw->glxDraw.config);
- #endif /* USE_GL */
- if (glw->glxDraw.overlay_info.exists)
- {
- _XtUnregisterWindow(glw->glxDraw.overlay_info.window,glw);
- glw->glxDraw.overlay_info.exists = FALSE;
- glw->glxDraw.overlay_info.window = NULL;
- /*The overlay window will be automatically destroyed when the
- *widget window is actually destroyed
- */
- }
- if (glw->glxDraw.underlay_info.exists)
- {
- _XtUnregisterWindow(glw->glxDraw.underlay_info.window,glw);
- glw->glxDraw.underlay_info.exists = FALSE;
- glw->glxDraw.underlay_info.window = NULL;
- /*The underlay window will be automatically destroyed when the
- *widget window is actually destroyed
- */
- }
- if (glw->glxDraw.popup_info.exists)
- {
- _XtUnregisterWindow(glw->glxDraw.popup_info.window,glw);
- glw->glxDraw.popup_info.exists = FALSE;
- glw->glxDraw.popup_info.window = NULL;
- /*The popup window will be automatically destroyed when the
- *widget window is actually destroyed
- */
- }
- #ifdef USE_GL
- GLXunlink(XtDisplay((Widget) glw), XtWindow((Widget) glw));
- #else
- #endif /* USE_GL */
- }
-
- /*------------------------------------------------------------------------
- * glxInput
- * Action routine for keyboard and mouse events
- * ARGSUSED
- *------------------------------------------------------------------------*/
-
- static void glxInput (glw, event, params, num_params)
- GlxDrawWidget glw;
- XEvent *event;
- String *params; /* unused */
- Cardinal *num_params; /* unused */
- {
- GlxDrawCallbackStruct cb;
-
- cb.reason = GlxCR_INPUT;
- cb.event = event;
- cb.window = XtWindow(glw);
- #ifdef USE_GL
- cb.buffer = GLX_NORMAL;
- #else
- cb.context = glw->glxDraw.context;
- #endif /* USE_GL */
- XtCallCallbackList ((Widget) glw, glw->glxDraw.input_callback, &cb);
- }
-
- /*------------------------------------------------------------------------
- * auxwindow_destroyed
- * If the user explicitly destroys the overlay or underlay windows,
- * clean up
- *------------------------------------------------------------------------*/
-
- static void auxwindow_destroyed(glw, client_data, event)
- GlxDrawWidget glw;
- caddr_t client_data;
- XEvent *event;
- {
- if (event->type == DestroyNotify && event->xdestroywindow.window)
- {
- if (glw->glxDraw.overlay_info.exists &&
- event->xdestroywindow.window == glw->glxDraw.overlay_info.window)
- {
- _XtUnregisterWindow(glw->glxDraw.overlay_info.window,glw);
- glw->glxDraw.overlay_info.exists = FALSE;
- glw->glxDraw.overlay_info.window = 0;
- }
- if (glw->glxDraw.underlay_info.exists &&
- event->xdestroywindow.window == glw->glxDraw.underlay_info.window)
- {
- _XtUnregisterWindow(glw->glxDraw.underlay_info.window,glw);
- glw->glxDraw.underlay_info.exists = FALSE;
- glw->glxDraw.underlay_info.window = 0;
- }
- if (glw->glxDraw.popup_info.exists &&
- event->xdestroywindow.window == glw->glxDraw.popup_info.window)
- {
- _XtUnregisterWindow(glw->glxDraw.popup_info.window,glw);
- glw->glxDraw.popup_info.exists = FALSE;
- glw->glxDraw.popup_info.window = 0;
- }
- }
- }
-
- #ifdef __GLX_MOTIF
-
- /*------------------------------------------------------------------------
- * GlxCreateMDraw
- * Provide a Motif-style create routine
- *------------------------------------------------------------------------*/
-
- Widget GlxCreateMDraw(parent, name, arglist, argcount)
- Widget parent;
- char *name;
- ArgList arglist;
- Cardinal argcount;
- {
- return (XtCreateWidget (name, glxMDrawWidgetClass, parent, arglist,
- argcount));
- }
- #endif
-
-